<template>
  <div>
    <input
      type="text"
      placeholder="请输入任务名称"
      v-model="value"
      @keydown.enter="enter"
    />
  </div>
</template>
<script>
import { defineComponent, ref } from "vue";
export default defineComponent({
  name: "navHeader",
  props: {},
  components: {},
  setup(props, ctx) {
    let value = ref("");
    // 添加任务 回车即可
    let enter = () => {
      // 传值给父组件
      ctx.emit("add", value.value);
      // 清空输入框
      value.value = "";
    };
    return {
      value,
      enter,
    };
  },
});
</script>
<style lang="scss" scoped>
input {
  width: 200px;
  height: 30px;
  margin-bottom: 8px;
}
</style>
